home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / misc / avmnfaxsrc1_33.lha / myinit.c < prev    next >
C/C++ Source or Header  |  1994-06-15  |  3KB  |  138 lines

  1. /* $Id: init.c,v 1.2 1993/06/11 16:29:21 Rhialto Exp $
  2.  * $Log: init.c,v $
  3.  * Revision 1.2  1993/06/11  16:29:21  Rhialto
  4.  * First real RCS checkin
  5.  *
  6.  */
  7.  
  8. /*
  9.  *  INIT.C
  10.  */
  11.  
  12. #include "defs.h"
  13. #include <clib/alib_protos.h>
  14. #include "exec/types.h"
  15. #include "devices/printer.h"
  16. #include "devices/prtbase.h"
  17.  
  18. Prototype void DevInit(void);
  19. Prototype void DevExpunge(void);
  20. Prototype int MsgRender(long ct, long x, long y, long status);
  21.  
  22. extern struct PrinterData *PD;
  23. extern struct PrinterExtendedData *PED;
  24.  
  25. /*
  26.  * The message interface.
  27.  */
  28.  
  29. struct PrtMsg {
  30.     struct Message  pm_Msg;
  31.     long        pm_Type;
  32. #define PM_RENDER   1
  33. #define PM_OPEN     2
  34. #define PM_CLOSE  3
  35. #define PM_DOSPECIAL 4
  36. #define PM_CONVFUNC 5
  37.  
  38. };
  39. #define pm_rc        pm_Type
  40.  
  41. struct RenderMsg {
  42.     struct PrtMsg   rm_PrtMsg;
  43.     long        rm_ct;
  44.     long        rm_x;
  45.     long        rm_y;
  46.     long        rm_status;
  47. };
  48.  
  49. struct PrtMsg   pm;
  50. struct RenderMsg rm;
  51.  
  52.  
  53. long SyncMsg(struct PrtMsg *m) {
  54.   struct MsgPort *ProcPort;
  55.   m->pm_Msg.mn_ReplyPort = (struct MsgPort*)FindTask(0); /* this cast is safe -- we'll
  56.                                 uncast this later */
  57.   Forbid();
  58.   ProcPort = FindPort("FAXPRINTERMP");
  59.   if (ProcPort) PutMsg(ProcPort, &m->pm_Msg);
  60.   Permit();
  61.   
  62.   if (ProcPort) {
  63.     do {
  64.       Wait(SIGF_SINGLE);
  65.     } while (m->pm_Msg.mn_Node.ln_Type != NT_REPLYMSG);
  66.   }
  67.   
  68.   return m->pm_rc;
  69. }
  70.  
  71. int MsgRender(long ct, long x, long y, long status) {
  72.   rm.rm_PrtMsg.pm_Type = PM_RENDER;
  73.   rm.rm_ct = ct;
  74.   rm.rm_x = x;
  75.   rm.rm_y = y;
  76.   rm.rm_status = status;
  77.  
  78.   if (status == 5) {
  79.     SetDensity(x & SPECIAL_DENSITYMASK);
  80.   }
  81.   return SyncMsg((struct PrtMsg*)&rm.rm_PrtMsg);
  82. }
  83.  
  84. int Close(struct printerIO *ior) {
  85.   pm.pm_Type = PM_CLOSE;
  86.   SyncMsg(&pm);
  87.   
  88.   return(0);
  89. }
  90.  
  91. int Open(struct printerIO* ior) {
  92.   rm.rm_PrtMsg.pm_Type = PM_OPEN;
  93.   /* the casts here are safe -- we're going to uncast them when this message
  94.      gets to the faxprinterdaemon */
  95.   rm.rm_ct = (long)PED;
  96.   rm.rm_x = 0;
  97.   rm.rm_y = 0;
  98.   rm.rm_status = (long)PD;
  99.  
  100.   SyncMsg((struct PrtMsg*)&rm);
  101.   
  102.   return(0);
  103. }
  104.  
  105. #define LPI             7
  106. #define CPI             15
  107. #define QUALITY         17
  108. #define INIT_LEN        30
  109. #define LPP             7
  110. #define FORM_LEN        11
  111. #define LEFT_MARG       3
  112. #define RIGHT_MARG      7
  113. #define MARG_LEN        12
  114.  
  115. int DoSpecial(UWORD* command, char outputBuffer[], BYTE* vline, BYTE* currentVMI, BYTE* crlfFlag, UBYTE Parms[]) {
  116.   rm.rm_PrtMsg.pm_Type = PM_DOSPECIAL;
  117.   rm.rm_ct = 0;
  118.   rm.rm_x = 0;
  119.   rm.rm_y = *vline;
  120.   rm.rm_status = *command;
  121.  
  122.   return SyncMsg((struct PrtMsg*)&rm);
  123. }
  124.  
  125. int ConvFunc(char* buf, char c, int flag) {
  126.   rm.rm_PrtMsg.pm_Type = PM_CONVFUNC;
  127.   rm.rm_ct = 0;
  128.   rm.rm_x = 0;
  129.   rm.rm_y = flag;
  130.   rm.rm_status = c;
  131.  
  132.   SyncMsg((struct PrtMsg*)&rm);
  133.  
  134.   buf[0] = '\0';
  135.   return(0); /* -1 == pass all chars back to the printer device */
  136. }
  137.  
  138.